hackerrank time complexity Primality problem